<template>
  <view>
    <view
      class="user-goods-item"
      v-for="(item, index) in goods_list"
      :key="index"
    >
      <image class="goods-img" :src="item.goods_pic" mode="" />
      <view class="godos-info">
        <view class="info-detail">
          <view class="goods-name">{{ item.goods_name }}</view>
          <view class="sku-info">
            <text
              style="margin-right: 6px"
              v-for="(attr, attrIndex) in item.attr_list"
              :key="attrIndex"
            >
              {{ attr.attr_group_name }}:{{ attr.attr_name }}
            </text>
          </view>
          <view class="price">
            <text>¥</text>
            <text>{{ item.price | priceBeforeZero }}</text>
            <text>{{ item.price | priceAfterZero }}</text>
          </view>
        </view>
        <view class="info-num">x{{ item.num }}</view>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  name: "",
  props: {
    goods_list: {
      type: Array,
      default: [],
    },
  },
  mixins: [],
  components: {},
  data() {
    return {};
  },

  mounted() {},
  watch: {},
  filters: {
    priceBeforeZero(val) {
      if (!val) val = "";
      val = val.toString();
      if (val.indexOf(".") < 0) return `${val}.`;
      return val.substr(0, val.indexOf("."));
    },
    priceAfterZero(val) {
      if (!val) val = "";
      val = val.toString();
      if (val.indexOf(".") < 0) return "00";
      return val.substr(val.indexOf("."), val.length);
    },
  },
  computed: {},
  methods: {},
};
</script>

<style lang="scss" scoped>
.user-goods-item {
  width: 100%;
  display: flex;
  align-items: flex-start;
  padding: 24rpx 0;
  border-bottom: 1px solid #f8f8f8;
  .goods-img {
    width: 166rpx;
    height: 166rpx;
    background: #f2f2f2;
    border-radius: 10rpx;
    flex-shrink: 0;
  }
  .godos-info {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-left: 20rpx;
    padding-right: 24rpx;
    .info-detail {
      flex: 1;
      .goods-name {
        font-size: 28rpx;
        font-family: PingFang SC;
        font-weight: 400;
        color: #262626;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        max-width: 464rpx;
      }
      .sku-info {
        font-size: 24rpx;
        font-family: PingFang SC;
        font-weight: 400;
        color: #8c8c8c;
        margin-top: 10rpx;
        max-width: 163px;
        word-break: break-all;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2; /* 这里是超出几行省略 */
        overflow: hidden;
      }
      .price {
        font-size: 32rpx;
        font-family: PingFang SC;
        font-weight: 600;
        color: #f0250e;
        margin-top: 14rpx;
        text:nth-child(1) {
          font-size: 24rpx;
        }
        text:nth-child(2) {
          font-size: 34rpx;
        }
        text:nth-child(3) {
          font-size: 24rpx;
        }
      }
    }
    .info-num {
      font-size: 24rpx;
      font-family: PingFang SC;
      font-weight: 400;
      color: #8c8c8c;
    }
  }
}
.user-goods-item:last-child {
  border-bottom: 0 none;
}
</style>
